/*
 * Copyright (C) 2010 Peter Schönhofen
 *
 * This file is part of the Akkad Compiler Framework.
 *
 * The Akkad Compiler Framework is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */

package hu.anaxo.akkad.processor.pl0

import hu.anaxo.akkad.processor.Syntax

/**
 * Generic statement
 */

abstract class Statement extends Syntax

/**
 * Block
 *
 * @param constants constants
 * @param variables variables
 * @param procedures procedures
 * @param statements statements
 */

case class Block(declarations: List[Declaration], statement: Statement) extends Statement

/**
 * Declaration
 */

abstract class Declaration extends Syntax

/**
 * Constant declaration
 *
 * @param name name
 * @param value value
 */

case class ConstantDef(name: String, value: Int) extends Declaration

/**
 * Variable declarations
 *
 * @param names names
 */

case class VariableDefs(names: List[String]) extends Declaration

/**
 * Procedure declaration
 *
 * @param name name
 * @param body body
 */

case class ProcedureDef(name: String, body: Statement) extends Declaration

/**
 * Assignment
 *
 * @param name variable name
 * @param expression value
 */

case class Assign(name: String, value: Expression) extends Statement

/**
 * Procedure call
 *
 * @param name procedure name
 */

case class Call(name: String) extends Statement

/**
 * Statements
 *
 * @param statements statements
 */

case class Statements(statements: List[Statement]) extends Statement

/**
 * IF-construct
 */

case class If(condition: Condition, body: Statement) extends Statement

/**
 * WHILE-construct
 */

case class While(condition: Condition, body: Statement) extends Statement

/**
 * Generic expression
 */

abstract class Expression extends Syntax

/**
 * Addition
 *
 * @param left left operand
 * @param right right operand
 */

case class Add(left: Expression, Right: Expression) extends Expression

/**
 * Subtraction
 *
 * @param left left operand
 * @param right right operand
 */

case class Subtract(left: Expression, Right: Expression) extends Expression

/**
 * Multiplication
 *
 * @param left left operand
 * @param right right operand
 */

case class Multiply(left: Expression, Right: Expression) extends Expression

/**
 * Division
 *
 * @param left left operand
 * @param right right operand
 */

case class Divide(left: Expression, Right: Expression) extends Expression

/**
 * Negation
 *
 * @param value value
 */

case class Negate(value: Expression) extends Expression

/**
 * Variable reference
 *
 * @param name variable name
 */

case class Reference(name: String) extends Expression

/**
 * Constant value
 *
 * @param value value
 */

case class Value(value: Int) extends Expression

/**
 * Generic condition
 */

abstract class Condition extends Syntax

/**
 * ODD operator
 *
 * @param value value
 */

case class Odd(value: Expression) extends Condition

/**
 * EQUAL operator
 *
 * @param left left operand
 * @param right right operand
 */

case class Equal(left: Expression, right: Expression) extends Condition

/**
 * LESS operator
 *
 * @param left left operand
 * @param right right operand
 */

case class Less(left: Expression, right: Expression) extends Condition

/**
 * GREATER operator
 *
 * @param left left operand
 * @param right right operand
 */

case class Greater(left: Expression, right: Expression) extends Condition

/**
 * NOT EQUAL operator
 *
 * @param left left operand
 * @param right right operand
 */

case class NotEqual(left: Expression, right: Expression) extends Condition

/**
 * LESS OR EQUAL operator
 *
 * @param left left operand
 * @param right right operand
 */

case class LessOrEqual(left: Expression, right: Expression) extends Condition

/**
 * GREATER OR EQUAL operator
 *
 * @param left left operand
 * @param right right operand
 */

case class GreaterOrEqual(left: Expression, right: Expression) extends Condition